package controller;

import javax.swing.JProgressBar;
import javax.swing.JTextPane;

import model.BinSetVariables;
import model.MonteCarloSimulationThreads;

/**
 * @author Estelle && Marie
 * This class is just to use for setting the text our main window and gets the result for a simulation without thread.
 * 
 */

public class MultiThread {
	
	public MultiThread(BinSetVariables variables, JTextPane text, JProgressBar pb){
		long a,b;
		double total;
		double res=0;
		StringBuilder buff = new StringBuilder();
		
		MonteCarloSimulationThreads h = new MonteCarloSimulationThreads(variables, pb);
			
		// we calcul the time of the excution
		a = System.nanoTime();		
				
		res = h.MonteCarloStandardOption();
	
		b = System.nanoTime();
		total = (b-a)/1000000000.0;
				
		// we display the result of our simulation in our window
		buff.append("Result : ").append(res).append("\n Beginning time : ").append(b).append("\n Ending time : ").append(b);
		buff.append("\nTotal time : " ).append(total).append(" sec");
		
		text.setText(buff.toString());
		pb.setValue(pb.getMaximum());
	}

}
